import config from './config.js'
export default (url, data = {}, method = "GET") => {
    return new Promise((resolve, reject) => {
        wx.request({
            url: config.url + url,
            data,
            method,
            header:{
              // MUSIC_U
              cookie:wx.getStorageSync('cookies')?wx.getStorageSync('cookies').find(item=>item.indexOf('MUSIC_U') != -1):''
            },
            success(res) {
              if(data.isLogin){
                // console.log(res);
                wx.setStorageSync('cookies', res.cookies)
              }
                resolve(res.data)
            },
            fail(err) {
                reject(err)
            }
        })
    })
    
}